package by.kniazhych.core.view.frames {
	import by.kniazhych.core.events.ApplicationEvent;
	import by.kniazhych.core.frames.ApplicationFrame;
	import by.vaukalak.core.display.utils.AssetsAcsessor;
	import design.menu.Menu;
	import flash.display.InteractiveObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Boutylin Mikhail
	 */
	
	
	
	public class MenuFrame extends BaseFrameView{
		
		private var _assetsAcsessor:AssetsAcsessor;
		
		public function MenuFrame() {
			_assetsAcsessor = new AssetsAcsessor(new Menu());
			addChild(_authorsButton);
			_authorsButton.addEventListener(MouseEvent.CLICK, _onAuthorsButtonClicked);
			addChild(_singleGameButton);
			_singleGameButton.addEventListener(MouseEvent.CLICK, _onSingleGameButtonClicked);
			addChild(_rulesButton);
			_rulesButton.addEventListener(MouseEvent.CLICK, _onRulesButtonClicked);
			addChild(_multyPlayerButton);
			_multyPlayerButton.addEventListener(MouseEvent.CLICK, _onMultyplayerButtonClicked);
		}
		
		//--------------------------------------------------------------------------
		//
		//  EVENT HANDLERS
		//
		//--------------------------------------------------------------------------
		
		private function _onSingleGameButtonClicked(e:MouseEvent):void {
			dispatchEvent(new ApplicationEvent(ApplicationEvent.FRAME_CHANGED, ApplicationFrame.SINGLE_GAME_BLACK));
		}
		
		private function _onMultyplayerButtonClicked(e:MouseEvent):void {
			dispatchEvent(new ApplicationEvent(ApplicationEvent.FRAME_CHANGED, ApplicationFrame.MULTYPLAYER));
		}
		
		private function _onRulesButtonClicked(e:MouseEvent):void {
			dispatchEvent(new ApplicationEvent(ApplicationEvent.FRAME_CHANGED, ApplicationFrame.RULES));
		}
		
		private function _onAuthorsButtonClicked(e:MouseEvent):void {
			dispatchEvent(new ApplicationEvent(ApplicationEvent.FRAME_CHANGED, ApplicationFrame.AUTHORS));
		}
		
		//--------------------------------------------------------------------------
		//
		//  PROPERTIE ACSESSORS
		//
		//--------------------------------------------------------------------------
		
		private function get _rulesButton():InteractiveObject {
			return _assetsAcsessor["rulesButton"] as InteractiveObject;
		}
		
		private function get _multyPlayerButton():InteractiveObject {
			return _assetsAcsessor["multyPlayerButton"] as InteractiveObject;
		}
		
		private function get _authorsButton():InteractiveObject {
			return _assetsAcsessor["authorsButton"] as InteractiveObject;
		}
		
		private function get _singleGameButton():InteractiveObject {
			return _assetsAcsessor["singleGameButton"] as InteractiveObject;
		}
		
	}

}